package com.tank.model;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.Random;

import com.tank.common.Dir;
import com.tank.config.ResourceMgr;

/**
 * 敌方坦克
 *
 * @author chenwb
 * @since 2024/1/27 14:25
 */
public class EnemyTank extends Tank {
    private static final BufferedImage defaultBufferedImage = ResourceMgr.getEnemyTankImage();
    public EnemyTank(int x, int y, Dir dir) {
        super(x, y, dir, defaultBufferedImage);
        super.setMoving(true);
    }

    private Random random = new Random();

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (random.nextInt(100) > 50) {
            super.fire();
        }
        if (random.nextInt(100) > 90) {
            super.setDir(Dir.values()[random.nextInt(4)]);
        }
    }
}
